<?php include('../variables/variables.php'); ?>

<?php

if(!session_id()) session_start(); 
$con = mysql_connect($dbserver, $dbuser, $dbpass);
if ($con)
{
	mysql_select_db($db, $con);

	if (isset($_POST['media_type_id']) && isset($_POST['name']) && isset($_POST['description']) && isset($_POST['checkout_duration']) && isset($_POST['renewal_limit']) && isset($_POST['late_fee']) && isset($_POST['fee_accumulation_time']))
	{
		$q = fquery($edit_media_type, array($_POST['name'] , $_POST['description'] , $_POST['checkout_duration'] , $_POST['renewal_limit'] , $_POST['late_fee']*100 , $_POST['fee_accumulation_time'], $_POST['media_type_id']));
		$result = mysql_query($q);
		mysql_close($con);
		if ($result)
		{
			header("location: /manage_media_types.php?msg=Media Type edited successfully");
		}
		else
		{
			header("location: /manage_media_types.php?err=Failed to edit themedia type.");
		}
	}
	else
	{
		mysql_close($con);
		header("location: /manage_media_types.php?err=Please fill in all fields");
	}
}

?>
